﻿// Original author contact info: Owen Emlen (owene_1998@yahoo.com)
// Note: other individuals may also have contributed to this code
// Project hosted on CodePlex.com as of 1/10/2009 at http://wpfimageviewer.codeplex.com
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using AForge.Imaging.Filters;
using BrainTechLLC;
using BrainTechLLC.ImageOperators;

namespace ImageAppDataModels
{
    public static class Util2
    {        
        public static bool WithinWidthHeightTolerance(double width, double height, double oldWidth, double oldHeight)
        {
            double widthDifference = Math.Abs(oldWidth - width);
            double heightDifference = Math.Abs(oldHeight - height);

            return (widthDifference <= 8D && heightDifference <= 8D);
        }

        public static bool WithinBounds(this double val, double low, double high)
        {
            return (val >= low && val <= high);
        }
        

        public static string CalculateMD5Hash(this byte[] bytes)
        {
            MD5 md5 = new MD5CryptoServiceProvider();
            byte[] retVal = md5.ComputeHash(bytes);
            ASCIIEncoding enc = new ASCIIEncoding();
            return enc.GetString(retVal);
        }        
    }
}
